<template>
  <div id="app">
    <mainheader v-on:openSidebar='ifsidebarOpen = !ifsidebarOpen' @openSearch = 'isSearch = true'></mainheader>
    <router-view name="findhead"
                 :headIndex='transformX'></router-view>
    <swiper :options="swiperOption"
            ref="mySwiper"
            class="main-wrap">
      <!-- slides -->
      <swiper-slide>
        <router-view name="Recommend"></router-view>
      </swiper-slide>
      <swiper-slide>
        <router-view name="Billboard"></router-view>
      </swiper-slide>
      <swiper-slide>I'm Slide 3</swiper-slide>
      <swiper-slide>I'm Slide 4</swiper-slide>
    </swiper>
    <myaudio v-if="isMusic"></myaudio>
    <sidebar v-if="ifsidebarOpen"></sidebar>
    <mymask v-if="ifsidebarOpen"
            @click.native='ifsidebarOpen =!ifsidebarOpen'></mymask>
    <musicListPage v-if='musicListPageStatus'></musicListPage>
    <search v-if="isSearch" @closeSearch = 'isSearch = false'></search>
    <playMusic v-if="isOpenPlayMusic"></playMusic>
  </div>
</template>

<script>
//  引入主页导航
import findhead from './components/findmusic/findhead/findhead.vue'
import Recommend from './components/findmusic/Recommend/Recommend.vue'
import mainheader from './components/utils/main-header/header.vue'
import myaudio from './components/audio/audio.vue'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
import sidebar from './components/utils/sidebar/sidebar'
import mymask from "./components/utils/mask/mask.vue"
import musicListPage from './components/utils/musicList/musicList'
import search from './components/search/search'
import playMusic from './components/utils/playMusic/playMusic'
export default {
  name: 'app',
  data() {
    const _this = this;
    return {
      swiperOption: {
        // autoHeight:true,
        // NotNextTick is a component's own property, and if notNextTick is set to true, the component will not instantiate the swiper through NextTick, which means you can get the swiper object the first time (if you need to use the get swiper object to do what Things, then this property must be true)
        // notNextTick是一个组件自有属性，如果notNextTick设置为true，组件则不会通过NextTick来实例化swiper，也就意味着你可以在第一时间获取到swiper对象，假如你需要刚加载遍使用获取swiper对象来做什么事，那么这个属性一定要是true
        notNextTick: true,
        // swiper configs 所有的配置同swiper官方api配置
        // if you need use plugins in the swiper, you can config in here like this
        // 如果自行设计了插件，那么插件的一些配置相关参数，也应该出现在这个对象中，如下debugger
        debugger: true,
        // swiper callbacks
        // swiper的各种回调函数也可以出现在这个对象中，和swiper官方一样
        onTransitionStart(swiper) {
          // console.log(swiper)
        },
        onSlideChangeEnd(swiper) {
          _this.transformX = swiper.realIndex;
        }
      },
      transformX: 0,
      ifsidebarOpen: false,
      isSearch:false
    }
  },
  components: {
    mainheader: mainheader,
    myaudio,
    swiper,
    swiperSlide,
    sidebar,
    mymask,
    musicListPage,
    search,
    playMusic
  },
  computed: {
    isMusic() {
      return this.$store.state.isMusic;
    },
    swiper() {
      return this.$refs.mySwiper.swiper;
    },
    musicListPageStatus() {
      return this.$store.state.isMusicList;
    },
    isOpenPlayMusic(){
      return this.$store.state.isOpenPlayMusic;
    }
  },
  methods: {
  },
  mounted() {

  }
}
</script>

<style scoped>
html,
body {
  height: 100%;
}

#app {
  padding-top: 2.3rem;
  box-sizing: border-box;
  height: 100%;
  overflow: auto;
}

.main-wrap {
  height: 100%;
}

.swiper-slide {
  min-height: 60%;
  overflow-y: auto;
}
</style>
